<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%  
	String path = request.getContextPath();  
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工列表</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/js/common/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath }/js/common/bootstrap/css/bootstrap-theme.min.css">
<script src="${pageContext.request.contextPath }/js/jquery-3.1.1.min.js"></script>
<script	src="${pageContext.request.contextPath }/js/common/bootstrap/js/bootstrap.min.js"></script>
<script	src="${pageContext.request.contextPath }/js/common/bootstrapvaildator/js/bootstrapValidator.min.js"></script>
<script	src="${pageContext.request.contextPath }/js/common/bootstrapvaildator/js/language/zh_CN.js"></script>
</head>
<!-- <body style="margin: 30px;"> -->
	<body>
		<!-- <div class="container"> -->
			<center>
				<!-- 条件查询表单 -->
				<form class="form-inline" action="${pageContext.request.contextPath }/zjj/selectBis_shop_user" method="post" name="myform" id="myform">
					<table>
						<tr align="center">
							<td align="right">
								<div class="form-group">
									<label for="account">员工账号：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="account" name="account" value="${account }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="username">姓名：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="username" name="username" value="${username }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="work_number">工号：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="work_number" name="work_number" value="${work_number }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="shop_name">店铺名称：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<select class="form-control" name="shop_id" id="shop_id">
									  	<option value="" selected="selected">请选择~！</option>
									  	<c:forEach items="${list2 }" var="list2">
											<option value="${list2.shop_id }">${list2.shop_name }</option>
										</c:forEach>
									</select>
								</div>
							</td>
							<!-- 表单按钮组 -->
							<td rowspan="2">
								<button class="btn btn-primary btn-sm" type="submit" name="zjjinquiry" id="zjjinquiry">
									<span class="glyphicon glyphicon-search" aria-hidden="true"></span>&nbsp;&nbsp;查询
								</button>
								&nbsp;&nbsp;
								<button class="btn btn-primary btn-sm" type="button" name="zjjresetting" id="zjjresetting">
									<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>&nbsp;&nbsp;重置
								</button>
							</td>
						</tr>
						<tr align="center">
							<td align="right">
								<div class="form-group">
									<label for="post_name">职位：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<select class="form-control" name="post_code" id="post_code">
									  	<option value="" selected="selected">请选择~！</option>
									  	<c:forEach items="${list3 }" var="list3">
											<%-- <option value="${list3.post_code }" <c:if test="${list3.post_code==post_code}">selected=selected</c:if>>${list3.post_name }</option> --%>
											<option value="${list3.post_code }">${list3.post_name }</option>
										</c:forEach>
									</select>
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="mobile">手机：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="mobile" name="mobile" value="${mobile }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="idno">身份证：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<input type="text" class="form-control" id="idno" name="idno" value="${idno }">
								</div>
							</td>
							<td align="right">
								<div class="form-group">
									<label for="status">状态：</label>
								</div>
							</td>
							<td align="left">
								<div class="form-group">
									<select class="form-control" name="status" id="status">
									  <option value="" selected="selected">请选择~！</option>
									  <%-- <option value="0" <c:if test="${status==0}">selected=selected</c:if>>离职</option> --%>
									  <option value="0">离职</option>
									  <option value="1">在职</option>
									</select>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="9">
								<!-- 功能组 -->
								<a href="${pageContext.request.contextPath }/zjj/staffinsert">
									<button type="button" class="btn btn-primary btn-sm" name="zjjadd" id="zjjadd">
										<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;&nbsp;新增
									</button>
								</a>
							</td>
						</tr>
					</table>
				</form>
				
				<!-- 显示数据 -->
				<table class="table table-bordered table-condensed table-hover">
					<tr align="center">
						<td></td>
						<td>员工账号</td>
						<td>姓名</td>
						<td>性别</td>
						<td>工号</td>
						<td>店铺名称</td>
						<td>职位</td>
						<td>手机</td>
						<td>身份证</td>
						<td>销售收入</td>
						<td>手工收入</td>
						<td>状态</td>
						<td>入职时间</td>
						<td>修改</td>
						<td>删除</td>						
					</tr>
					<c:forEach items="${info.list }" var="list" varStatus="s">
						<tr align="center">
							<td>${s.index+1 }</td>
							<td>${list.account }</td>
							<td>${list.username }</td>
							<%-- <td>${list.sex }</td> --%>
							<td>
								<c:if test="${list.sex==1 }">
									男
								</c:if>
								<c:if test="${list.sex==2 }">
									女
								</c:if>
								<c:if test="${list.sex==3 }">
									保密
								</c:if>
							</td>
							<td>${list.work_number }</td>
							<td>${list.shop_name }</td>
							<td>${list.post_name }</td>
							<td>${list.mobile }</td>
							<td>${list.idno }</td>
							<td></td>
							<td></td>
							<%-- <td>${list.status }</td> --%>
							<td>
								<c:if test="${list.status==0 }">
									离职
								</c:if>
								<c:if test="${list.status==1 }">
									在职
								</c:if>
							</td>
							<%-- <td>${list.create_time }</td> --%>
							<td>
								<f:formatDate value="${list.create_time }" pattern="yyyy-MM-dd" />
							</td>
							<td>
								<a href="${pageContext.request.contextPath }/zjj/findByIdBis_shop_user?shop_user_id=${list.shop_user_id}">
									<button type="button" class="btn btn-primary btn-xs">
										<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;&nbsp;修改
									</button>
								</a>
							</td>
							<td>
								<button class="btn btn-primary btn-xs" type="button" onclick="test2('${list.shop_user_id}')" data-toggle="modal" data-target="#myModal1" data-backdrop="static">
									 <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>&nbsp;&nbsp;删除
								</button>
							</td>
						</tr>
					</c:forEach>
				</table>
				
				<!-- 删除账户模态框 -->
				<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
				  <div class="modal-dialog" role="document">
				    <div class="modal-content">
				      <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				        <h4 class="modal-title" id="myModalLabel">删除</h4>
				      </div>
				      <div class="modal-body">
				        <form class="form-horizontal" name="myform2" id="myform2">
				        	<input type="hidden" name="shop_user_id" id="shop_user_id1" value="">
						  <div class="form-group"">
						  	<h3><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>&nbsp;&nbsp;你确定要删除该员工吗？</h3>
						  </div>
						  <div class="form-group"">
						  	<button type="button" class="btn btn-default" name="zjjdelete" id="zjjdelete">确定</button>
					        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					      </div>
						</form>
				      </div>
				    </div>
				  </div>
				</div>
				
				<!-- 分页 -->
				<a href="#" onclick="first()">首页</a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="pre()">上一页</a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="next()">下一页</a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" onclick="last()">尾页</a>
			</center>
		<!-- </div> -->
	</body>

</html>
<script type="text/javascript">
	//条件查询定值方法
	$(function(){
		$("#shop_id").val('${shop_id}');
		$("#post_code").val('${post_code}');
		$("#status").val('${status}');
	})
	
	//分页
	//首页
	function first(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_shop_user?page=${info.firstPage}";
		document.forms[0].submit();lase
	}
	//上一页
	function pre(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_shop_user?page=${info.prePage}";
		document.forms[0].submit();
	}
	//下一页
	function next(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_shop_user?page=${info.nextPage}";
		document.forms[0].submit();
	}
	//尾页
	function last(){
		document.forms[0].action="${pageContext.request.contextPath }/zjj/selectBis_shop_user?page=${info.lastPage}";
		document.forms[0].submit();
	}
	
	//点击重置按钮 重置
	$("#zjjresetting").click(
		function() {
			$("#account").val("");
			$("#username").val("");
			$("#work_number").val("");
			$("#shop_id").val("");
			$("#post_code").val("");
			$("#mobile").val("");
			$("#idno").val("");
			$("#status").val("");
		}
	);
	
	//点击删除按钮 将当前行数据ID传递到模态框
	function test2 (id1) {
        $("#shop_user_id1").val(id1);
    }
	
	//删除
	//点击确定按钮 提交表单 删除
	$("#zjjdelete").click(
		function() {
			$.ajax({
				type : "POST",
				url : "${pageContext.request.contextPath }/zjj/deleteBis_shop_user",
				data : $("#myform2").serialize(),
				success : function(result) {
					//由于ajax发送的url到控制层不会进行页面的跳转，因为当请求成功以后，请求依然会回success,所以可以在此再写一遍url进行跳转
					window.location.href = "${pageContext.request.contextPath }/zjj/selectBis_shop_user";
				}
			});
	});

</script>